﻿using System;
using System.Web;
using System.Web.Mvc;
using ControleRepresentante.Common;

namespace WebSite.ViewModels.Fields
{
    public class LabelField : IField
    {
        public string Name { get; private set; }
        public object Value { get; private set; }

        public LabelField(string caption, string name, object value, bool isOneRow = false)
        {
            Name = name;
            Value = value;
            Caption = caption;
            IsOneRow = isOneRow;
        }

        public string Caption { get; private set; }

        public IHtmlString Render(HtmlHelper htmlHelper)
        {
            return MvcHtmlString.Create(Value.FormatForDisplay());
        }

        public bool IsOneRow { get; private set; }

        public bool IsEmpty
        {
            get { return Value == null || String.IsNullOrEmpty(Value.ToString()); }
        }
    }
}